<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require '../com.swiss.mooh.dao.impl/CarouselDaoImpl.php';
require '../com.swiss.mooh.service/CarouselServiceImpl.php';
require '../com.swiss.mooh.model/Carousel.php';

$dispatcher = new CarouselDaoImpl();
$caService = new CarouselServiceImpl($dispatcher);


if (move_uploaded_file($_FILES["leftCaFileName"]["tmp_name"], "../../assets/images/uploads/images/" . $_FILES["leftCaFileName"]["name"])) {
    $caObj = new Carousel();
    $caObj->setCaID(uniqid());
    $caObj->setCaFilePath("../../assets/images/uploads/images/" . $_FILES["leftCaFileName"]["name"]);
    $caObj->setCaLink($_POST['leftCaLink']);
    $caObj->setCaName($_FILES["leftCaFileName"]["name"]);
    $caObj->setCaPosition("LEFT");
    $result = $caService->createLeftCarousel($caObj);
    if ($result == 200) {
        header("Location: ../../manage_carousel_page.php");
        exit();
    } else {
        echo $result;
    }
} else {
    echo "Cannot move file to folder";
}



